package com.ruoyi.web.controller.wuyi;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wuyi.domain.WyShouyaoInfo;
import com.ruoyi.wuyi.service.IWyShouyaoInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 兽药产品Controller
 * 
 * @author ruoyi
 * @date 2022-07-18
 */
@RestController
@RequestMapping("/wuyi/shouyao")
public class WyShouyaoInfoController extends BaseController
{
    @Autowired
    private IWyShouyaoInfoService wyShouyaoInfoService;

    /**
     * 查询兽药产品列表
     */
    @PreAuthorize("@ss.hasPermi('wuyi:shouyao:list')")
    @GetMapping("/list")
    public TableDataInfo list(WyShouyaoInfo wyShouyaoInfo)
    {
        startPage();
        List<WyShouyaoInfo> list = wyShouyaoInfoService.selectWyShouyaoInfoList(wyShouyaoInfo);
        return getDataTable(list);
    }

    /**
     * 导出兽药产品列表
     */
    @PreAuthorize("@ss.hasPermi('wuyi:shouyao:export')")
    @Log(title = "兽药产品", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WyShouyaoInfo wyShouyaoInfo)
    {
        List<WyShouyaoInfo> list = wyShouyaoInfoService.selectWyShouyaoInfoList(wyShouyaoInfo);
        ExcelUtil<WyShouyaoInfo> util = new ExcelUtil<WyShouyaoInfo>(WyShouyaoInfo.class);
        util.exportExcel(response, list, "兽药产品数据");
    }

    /**
     * 获取兽药产品详细信息
     */
    @PreAuthorize("@ss.hasPermi('wuyi:shouyao:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(wyShouyaoInfoService.selectWyShouyaoInfoById(id));
    }

    /**
     * 新增兽药产品
     */
    @PreAuthorize("@ss.hasPermi('wuyi:shouyao:add')")
    @Log(title = "兽药产品", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WyShouyaoInfo wyShouyaoInfo)
    {
        return toAjax(wyShouyaoInfoService.insertWyShouyaoInfo(wyShouyaoInfo));
    }

    /**
     * 修改兽药产品
     */
    @PreAuthorize("@ss.hasPermi('wuyi:shouyao:edit')")
    @Log(title = "兽药产品", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WyShouyaoInfo wyShouyaoInfo)
    {
        return toAjax(wyShouyaoInfoService.updateWyShouyaoInfo(wyShouyaoInfo));
    }

    /**
     * 删除兽药产品
     */
    @PreAuthorize("@ss.hasPermi('wuyi:shouyao:remove')")
    @Log(title = "兽药产品", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wyShouyaoInfoService.deleteWyShouyaoInfoByIds(ids));
    }
}
